package com.springboot.cloud.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.springboot.cloud.dao.ArticleMapper;
import com.springboot.cloud.entities.Article;

@Service
public class ArticleService {
	@Autowired
	private ArticleMapper articlemapper;

	public List<Article> geta(int start,int limit) {
		return articlemapper.geta( start, limit);
	}

	public boolean adda(Article a) {
		return articlemapper.adda(a);
	}

	public Article getone(int id) {
		return articlemapper.getone(id);
	}

	public List<Article> getmyarticle(int id) {
		return articlemapper.getmyarticle(id);
	}

	public List<Article> getfavorite(int id) {
		return articlemapper.getfavorite(id);
	}
	public boolean addlike(int id) {
		return articlemapper.add1ike(id);
	}
	public boolean addnolike(int id) {
		return articlemapper.addno1ike(id);
	}

	public boolean addfavorite(int id, int aid) {
		return articlemapper.addfavorite(id,aid);
	}
	
//	// 从缓存中获取用户信息
//	String key = "user_" + id;
//	ValueOperations<String, User> operations = redisTemplate.opsForValue();
//	// 缓存存在
//	boolean hasKey = redisTemplate.hasKey(key);
//	if (hasKey) {
//		User user = operations.get(key);
//		System.out.println("从redis获取");
//		return user;
//	}
//	// 缓存不存在，从 DB 中获取

}
